package com.eastmoney.emis.edda.infrastructure.constraint.repository;

import com.eastmoney.emis.edda.domain.repository.EddaApplyTimesLimitRepository;
import com.eastmoney.emis.edda.infrastructure.constraint.mapper.EmhkConfigMapper;
import com.eastmoney.emis.edda.infrastructure.constraint.po.EmhkConfigPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.infrastructure.constraint.repository
 * @author: 汪程程
 * @date: 2022/12/14 10:42 AM
 * @version: 1.0
 */
@Repository
public class EddaApplyTimesLimitRepositoryImpl implements EddaApplyTimesLimitRepository {

    @Autowired
    private EmhkConfigMapper configMapper;

    @Override
    public int getMaxApplyTimesDaily() {
        EmhkConfigPo configPo = configMapper.getEmhkConfigByConfigKeyAndBusinessKey("ClientDDAMaxNo", "HSBCEDDA");
        return Optional.ofNullable(configPo)
                .map(r -> Integer.parseInt(r.configValue))
                .orElse(10);
    }
}
